package com.fancy.common;

/**
 * 上传图片类型
 * 
 */
public enum StoreFileTypeEnum {
	
	TEMPLATE(500, "template"),
	
	/**
	 * 内容图片类型
	 */
	UPLOAD(600, "upload"),
	
	//Ckfinder
	FILES(700, "file"),
	
	IMAGES(800, "image"),
	
	FLASH(900, "flash"),
	
	MEDIA(1400, "media"),

	/**
	 * 临时目录
	 */
	TEMP(10000, "temp"),
	
	/**
	 * 图文封面图片
	 */
	PAGE(1000, "page"),
	
	/**
	 * 会员
	 */
	MEMBER(1100, "member"),
	
	/**
	 * 投票
	 */
	VOTE(1200, "vote"),

	/**
	 * 微餐饮
	 */
	FOOD(1300, "food"),
	
		/**
	 * 新闻图片类型
	 */
	QRCODE(1400, "qrcode")
	
	;

	private final int code;
	private final String name;

	private StoreFileTypeEnum(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public int getValue() {
		return this.code;
	}

	public String toString() {
		return this.name;
	}

	public static StoreFileTypeEnum getType(final int code) {
		for (StoreFileTypeEnum type : StoreFileTypeEnum.values()) {
			if (type.code == code) {
				return type;
			}
		}
		throw new IllegalArgumentException("wrong StoreFileTypeEnum");
	}
	
	public static StoreFileTypeEnum getType(final String name) {
		for (StoreFileTypeEnum ds : StoreFileTypeEnum.values()) {
			if (ds.name.equals(name)) {
				return ds;
			}
		}
		return null;
	}
}